package com.test.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;


@ApiModel("返回列表对象")
public class ResultList implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * 总数默认-1，当为-1时说明此字段前端不需要
     */
    @ApiModelProperty(value = "总数", dataType = "long", required = true)
    private long count;
    /**
     * 返回数组
     */
    @ApiModelProperty(value = "返回数组", dataType = "Array", required = true)
    private Collection list;

    public static ResultList instance(Collection list, long count){
        ResultList listObject = new ResultList();
        if(null == list || list.size() <= 0){
            listObject.setList(new ArrayList());
        }else {
            listObject.setList(list);
        }
        listObject.setCount(count);
        return listObject;
    }

    public static ResultList instance(Collection list, Long count){
        return instance(list,count) ;
    }

    public static ResultList instance(Collection list){
        return instance(list,0) ;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public Collection getList() {
        return list;
    }

    public void setList(Collection list) {
        this.list = list;
    }
}
